import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.bind.JAXBException;

import util.CalSerializer;
import vo.Cal;
import vo.Task;


public class Main_tester {

	/**
	 * @param args
	 * @throws JAXBException 
	 */
	public static void main (String[] args) throws IOException {

		try {

			String path = "src/task-manager-xml.xml";

			//FileInputStream stream = new FileInputStream(path);

			//JAXBContext jaxbContext = JAXBContext.newInstance(Cal.class);

			//deserialize

			//Cal myCal = (Cal) jaxbContext.createUnmarshaller().unmarshal(stream);

			Cal myCal = CalSerializer.unMarshallCal(path);

			//List<User> user = myCal.users;
			//List<Task> tasks = myCal.tasks;

			// User newUser = new User("jaje" , "Jacob Brandt Jensen" , "2233");
			// user.add(newUser);

			// Test if user exists
			if (myCal.containsUser("jaje")) {System.out.println(myCal.getUser("jaje").toString());}
			
			//Test if task exists
								
			
			Task newTask = new Task("test3", "test33.  task", "25-12-2012", "a 3. test task", "jaje");
			
			System.out.println(myCal.getUserTaskList("jaje").toString());
			System.out.println(myCal.deleteTask("a test Task"));
			myCal.addTask(newTask);
			myCal.updateTask(newTask);
			
						
			CalSerializer.save(myCal, path);


		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		

	}


}
